Page({
    data: {
        tabNav: [
            { show: true, value: 'buyer' },
            { show: false, value: 'platform' },
            { show: true, value: 'supplier' }
        ],
        TabCur: 'buyer',
        isRead: true,
        name: '',
        type: '2',

        //新增商品进入传参
        sellearAdd: false,
        //修改客户进入参数
        edit: {
            sellearEdit: false,
            customerType: null,
            nature: null,
            group_id: null,
            groupName: '',
            phone: '',
            linkman: '',
            address: '',
            license:'',
            chemical:'',
            wholesale:'',
            other:'',
            licenseCode:'',
            legalGrant:''
        }

    },
    onLoad(options) {
        this.data.sellearAdd = options.sellearAdd
        this.data.edit.sellearEdit = options.sellearEdit
        this.data.edit.customerType = options.customerType
        if (this.data.edit.sellearEdit) {
            if (this.data.edit.customerType == 2) {
                this.data.TabCur = 'buyer'
            } else if (this.data.edit.customerType == 1) {
                this.data.TabCur = 'supplier'
            }
            this.data.isRead = true;
            this.data.edit.id = options.id;
            this.data.edit.nature = options.nature;
            this.data.edit.group_id = options.group_id;
            this.data.edit.groupName = options.groupName;
            this.data.edit.address = options.address;
            this.data.edit.linkman = options.linkman;
            this.data.edit.phone = options.phone;
            this.data.edit.license = options.license;
            this.data.edit.chemical = options.chemical;
            this.data.edit.wholesale = options.wholesale;
            this.data.edit.other = options.other;
            this.data.edit.licenseCode = options.licenseCode;

            this.data.edit.legalPersonCode = options.legalPersonCode;
            this.data.edit.legalPerson1 = options.legalPerson1;
            this.data.edit.legalPerson2 = options.legalPerson2;
            this.data.edit.accountLicense = options.accountLicense;
            this.data.edit.banknum = options.banknum;
            this.data.edit.bankname = options.bankname;
            this.data.edit.legalGrant = options.legalGrant;

            this.setData({
                TabCur: this.data.TabCur,
                type: this.data.edit.customerType,
                name: options.name,
                isRead: this.data.isRead
            })
        }
    },
    CheckboxChange() {
        this.data.isRead = !this.data.isRead
        this.setData({
            isRead: this.data.isRead
        })
    },
    nextStep() {
        if (this.data.name == "" || this.data.name == null) {
            wx.showToast({
                icon: 'none',
                title: '请输入公司名称',
            })
            return false
        }
        if (this.data.isRead == false) {
            wx.showToast({
                icon: 'none',
                title: '请先阅读并同意《长期购销合作委托协议》'
            })
            return false
        }
        wx.navigateTo({
            url: '/pages/pagesUser/companyInfo/attestationCompany?name=' + this.data.name
                + '&type=' + this.data.type
                + '&sellearAdd=' + this.data.sellearAdd
                + '&sellearEdit=' + this.data.edit.sellearEdit
                + '&nature=' + this.data.edit.nature
                + '&group_id=' + this.data.edit.group_id
                + '&groupName=' + this.data.edit.groupName
                + '&linkman=' + this.data.edit.linkman
                + '&phone=' + this.data.edit.phone
                + '&address=' + this.data.edit.address
                + '&license=' + this.data.edit.license
                + '&chemical=' + this.data.edit.chemical
                + '&wholesale=' + this.data.edit.wholesale
                + '&licenseCode=' + this.data.edit.licenseCode
                + '&id=' + this.data.edit.id
                + '&other=' + this.data.edit.other

                + '&legalPersonCode=' + this.data.edit.legalPersonCode
                + '&legalPerson1=' + this.data.edit.legalPerson1
                + '&legalPerson2=' + this.data.edit.legalPerson2
                + '&accountLicense=' + this.data.edit.accountLicense
                + '&banknum=' + this.data.edit.banknum
                + '&bankname=' + this.data.edit.bankname
                + '&legalGrant=' + this.data.edit.legalGrant
        })
    },
    bindOrgName(data) {
        this.data.name = data.detail.value
        this.setData({
            name: this.data.name
        })
    },
    tabSelect(e) {
        this.data.TabCur = e.currentTarget.dataset.id
        if (this.data.TabCur == 'buyer') {
            this.data.type = 2
        } else if (this.data.TabCur == 'supplier') {
            this.data.type = 1
        }
        this.setData({
            TabCur: this.data.TabCur,
            type: this.data.type
        })
    }
});